package com.manli.api.service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.manli.api.base.exception.MyException;
import com.manli.api.dao.ActivityGoodsDao;
import com.manli.api.dao.GoodsModelDao;
import com.manli.api.dto.*;
import com.manli.api.pojo.*;
import com.manli.api.util.*;
import com.manli.common.utils.StringUtil;
import com.manli.wechat.utils.WeChat;
import com.manli.wechat.utils.wechattemplate.WeixinTemplateSender;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.beetl.sql.core.SQLManager;
import org.beetl.sql.core.SQLReady;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.*;
import java.util.stream.Collectors;

import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import com.manli.api.dao.GoodsDefDao;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;

@Slf4j
@Service("goodsDefService")
public class GoodsDefService {
    @Autowired
    GoodsDefDao goodsDefDao;
    @Autowired
    SQLManager sqlManager;
    @Autowired
    SessionInfoUtils sessionInfoUtils;
    @Autowired
    private ActivityGoodsDao activityGoodsDao;
    @Autowired
    private WeChatPushMessageUtil weChatPushMessageUtil;
    @Autowired
    private GoodsModelDao goodsModelDao;

    
    public Result queryPage(QueryParams params) {
        StringBuffer sql = new StringBuffer("select * from goods_def where 1=1 ");

        SQLReady sqlReady = new SQLReady(sql.toString());

        PageQuery<GoodsDef> pageQuery = new PageQuery<GoodsDef>(params.getPage(),params.getLimit());
        PageQuery<GoodsDef> query =sqlManager.execute(sqlReady,GoodsDef.class,pageQuery);
        return ResultUtil.success(query.getList(),query.getTotalRow());
    }

    public Result queryPage1(QueryParamsGoodsDefs params) {
        StringBuffer sql = new StringBuffer("SELECT " +
                " a.*, " +
                " d.activity_type_name, " +
                " b.branch_name, " +
                " c.partner_name, " +
                "CASE " +
                "  WHEN buy_method = '1' THEN " +
                "  '到店自取'  " +
                "  WHEN buy_method = '2' THEN " +
                "  '商家配送'  " +
                "  WHEN buy_method = '3' THEN " +
                "  '平台配送'  " +
                " END AS buy_method_name , " +
                " CASE " +
                "  WHEN a.status = -2 THEN " +
                "  '草稿'  " +
                "  WHEN a.status = -1 THEN " +
                "  '待审核'  " +
                "  WHEN a.status = 0 THEN " +
                "  '退回'  " +
                "  WHEN a.status = 1 THEN " +
                "  '上架成功' " +
                "  WHEN a.status = 2 THEN " +
                "  '下架' " +
                " END AS goods_status " +
                "FROM " +
                " goods_def a " +
                " LEFT JOIN branch b ON a.branch_id = b.branch_id " +
                " LEFT JOIN partner c ON a.partner_id = c.partner_id left join activity_type d on a.apply_activity_type_id = d.activity_type_id where a.status != -3  ");

        sql.append(StringUtils.isEmpty(params.getGoodsName())?"":" and a.goods_name like '%" + params.getGoodsName() + "%'");
        sql.append(params.getBranchId() == null?"":" and a.branch_id = " + params.getBranchId());
        sql.append(params.getPartnerId() == null?"":" and a.partner_id = " + params.getPartnerId());
        sql.append(params.getStatus() == null?"":" and a.status = " + params.getStatus());
        sql.append(" order by a.status ");

        SQLReady sqlReady = new SQLReady(sql.toString());

        PageQuery<GoodsDef> pageQuery = new PageQuery<GoodsDef>(params.getPage(),params.getLimit());
        PageQuery<GoodsDef> query =sqlManager.execute(sqlReady,GoodsDef.class,pageQuery);

        //商品主营类别查询
        if(query.getList() != null && query.getList().size() > 0){
            SQLReady sqlReady1 = new SQLReady("select * from major_type where status = 1");
            List<MajorType> majorTypes =  sqlManager.execute(sqlReady1, MajorType.class);


            query.getList().forEach(goodsDef -> {
                JSONArray names = new JSONArray();
                if(goodsDef.getGoodsMajorType() != null){
                    JSONArray list = JSONArray.parseArray(goodsDef.getGoodsMajorType());
                    list.forEach(s -> {
                        List<MajorType> list1 = majorTypes.stream().filter(majorType -> s.toString().equals(majorType.getMajorTypeId().toString())).collect(Collectors.toList());
                        if(list1 != null && list1.size() > 0){
                            names.add(list1.get(0).getMajorName());
                        }
                    });
                }
                goodsDef.setGoodsMajorTypeName(names.toJSONString());
            });
        }

        return ResultUtil.success(query.getList(),query.getTotalRow());
    }

    public Result queryPage2(QueryParamsGoodsDefsVer params) {
        StringBuffer sql = new StringBuffer("SELECT " +
                " a.*, " +
                " d.activity_type_name, " +
                " b.branch_name, " +
                " c.partner_name, " +
                "CASE " +
                "  WHEN buy_method = '1' THEN " +
                "  '到店自取'  " +
                "  WHEN buy_method = '2' THEN " +
                "  '商家配送'  " +
                "  WHEN buy_method = '3' THEN " +
                "  '平台配送'  " +
                " END AS buy_method_name , " +
                " CASE " +
                "  WHEN a.status = -2 THEN " +
                "  '草稿'  " +
                "  WHEN a.status = -1 THEN " +
                "  '待审核'  " +
                "  WHEN a.status = 0 THEN " +
                "  '退回'  " +
                "  WHEN a.status = 1 THEN " +
                "  '上架成功' " +
                "  WHEN a.status = 2 THEN " +
                "  '下架' " +
                " END AS goods_status " +
                "FROM " +
                " goods_def a " +
                " LEFT JOIN branch b ON a.branch_id = b.branch_id " +
                " LEFT JOIN partner c ON a.partner_id = c.partner_id left join activity_type d on a.apply_activity_type_id = d.activity_type_id where a.status != -3  ");

        sql.append(StringUtils.isEmpty(params.getGoodsName())?"":" and a.goods_name like '%" + params.getGoodsName() + "%'");
        sql.append(params.getBranchId() == null?"":" and a.branch_id = " + params.getBranchId());
        sql.append(params.getPartnerId() == null?"":" and a.partner_id = " + params.getPartnerId());
        sql.append(params.getStatus() == null?"":" and a.status in " + ObjectEmptyUtil.listToSqlIn(params.getStatus()));
        sql.append(" order by a.status ");
        SQLReady sqlReady = new SQLReady(sql.toString());

        PageQuery<GoodsDef> pageQuery = new PageQuery<GoodsDef>(params.getPage(),params.getLimit());
        PageQuery<GoodsDef> query =sqlManager.execute(sqlReady,GoodsDef.class,pageQuery);
        return ResultUtil.success(query.getList(),query.getTotalRow());
    }

    
    public Result queryAll(QueryParamsGoodsDefs params) {
        StringBuffer sql = new StringBuffer("SELECT " +
                " a.*, " +
                " b.branch_name, " +
                " c.partner_name, " +
                "CASE " +
                "  WHEN buy_method = '1' THEN " +
                "  '到店自取'  " +
                "  WHEN buy_method = '2' THEN " +
                "  '商家配送'  " +
                "  WHEN buy_method = '3' THEN " +
                "  '平台配送'  " +
                " END AS buy_method_name , " +
                " CASE " +
                "  WHEN a.status = -2 THEN " +
                "  '草稿'  " +
                "  WHEN a.status = -1 THEN " +
                "  '待审核'  " +
                "  WHEN a.status = 0 THEN " +
                "  '退回'  " +
                "  WHEN a.status = 1 THEN " +
                "  '上架成功' " +
                "  WHEN a.status = 2 THEN " +
                "  '下架' " +
                " END AS goods_status " +
                "FROM " +
                " goods_def a " +
                " LEFT JOIN branch b ON a.branch_id = b.branch_id " +
                " LEFT JOIN partner c ON a.partner_id = c.partner_id where a.status != -3  ");

        sql.append(StringUtils.isEmpty(params.getGoodsName())?"":" and a.goods_name like '%" + params.getGoodsName() + "%'");
        sql.append(params.getBranchId() == null?"":" and a.branch_id = " + params.getBranchId());
        sql.append(params.getPartnerId() == null?"":" and a.partner_id = " + params.getPartnerId());
        sql.append(params.getStatus() == null?"":" and a.status = " + params.getStatus());

        List<GoodsDef> list = goodsDefDao.execute(sql.toString());
        return ResultUtil.success(list);
    }

    
    public Result getById(Integer goodsDefId) {
        GoodsDef goodsDef = goodsDefDao.single(goodsDefId);
        return ResultUtil.success(goodsDef);
    }

    @Transactional
    public Result save(GoodsDef goodsDef, HttpServletRequest request) {
        SessionInfo sessionInfo = sessionInfoUtils.getSessionInfoByAuth(request);
        //判断值为空
        ObjectEmptyUtil.goodsdefIsEmpty(goodsDef);
        goodsDef.setCreaterUserid(sessionInfo.getUserId());
        goodsDef.setUpdaterUserid(sessionInfo.getUserId());
        goodsDef.setUpdateTime(new Date());
        goodsDef.setCreateTime(new Date());

        Integer goodsId = Integer.parseInt(goodsDefDao.insertReturnKey(goodsDef).getKey().toString());

        //商品规格添加
        if(goodsDef.getGoodsModels().size() == 0){
            throw new MyException(-1,"商品规格至少需要一种");
        }
        goodsDef.getGoodsModels().forEach(goodsModel -> {
            //判断值为空
            ObjectEmptyUtil.goodsModelIsEmpty(goodsModel);

            //如果是活动商品，只能添加一种商品规格
            String sql = "select * from goods_def where goods_def_id = ?";
            SQLReady sqlReady = new SQLReady(sql,goodsId);
            List<GoodsDef> defList = sqlManager.execute(sqlReady, GoodsDef.class);
            if(defList.size()> 0){
                if(defList.get(0).getApplyActivityTypeId() != null){
                    List<GoodsModel> list1 = goodsModelDao.execute("select * from goods_model where goods_def_id = ?",goodsId);
                    if(list1.size() > 0){
                        throw new MyException(-1,"活动商品规格只能有一种");
                    }
                }
            }

            List<GoodsModel> list = goodsModelDao.execute("select * from goods_model where goods_model_name = ? and goods_def_id = ?",goodsModel.getGoodsModelName(),goodsId);
            if(list.size() > 0){
                throw new MyException(-1,"规格名" + goodsModel.getGoodsModelName() + "重复");
            }
            goodsModel.setGoodsDefId(goodsId);
            goodsModelDao.insert(goodsModel);
        });

        //如果是活动商品。上架的时候才能插入活动表，新增的时候不能插入。

        return ResultUtil.success(goodsId);
    }

    @Transactional
    public Result updateById(GoodsDef goodsDef, HttpServletRequest request) {
        //判断值为空
        ObjectEmptyUtil.goodsdefIsEmpty(goodsDef);

        List<GoodsDef> goodsDefs = goodsDefDao.execute("select * from goods_def where goods_def_id = ?",goodsDef.getGoodsDefId());
        //查询改商品记录的更新人openid
        String sql1 = "select b.openid from user_link_unionid a left join we_chat_user_info b on a.unionid = b.unionid where a.user_id = ? and b.source = 1";
        SQLReady sqlReady1 = new SQLReady(sql1,goodsDefs.get(0).getUpdaterUserid());
        List<String> openid = sqlManager.execute(sqlReady1,String.class);
        //下架商品需要判断是否为活动商品，以及是否在活动时间内下架，活动时间内不允许下架
        if(goodsDef.getStatus().intValue() == 2){
            if(goodsDefs.size() > 0){
                if(goodsDefs.get(0).getApplyActivityTypeId() != null){
                    String sql = "select * from activity_goods where goods_def_id = ? and status = '1' and now() >= activity_start_time and now() <= activity_end_time";
                    SQLReady sqlReady = new SQLReady(sql,goodsDef.getGoodsDefId());
                    List<Map> activityGoods = sqlManager.execute(sqlReady,Map.class);
                    if(activityGoods.size() > 0){
                        //该商品活动已经开始，不允许下架
                        return ResultUtil.error(-1,"该商品活动已经开始，不允许下架");
                    }
                }
            }
        }

        //审核上架商品需要判断是否为活动商品，以及是否修改过活动类型和活动时间，修改过不允许审核通过上架
        if(goodsDef.getStatus().intValue() == 1){
            if(goodsDefs.size() > 0){
                if(goodsDefs.get(0).getApplyActivityTypeId() != null){
                    if(goodsDef.getVerifiedApplyActivityStartTime() == null || goodsDef.getVerifiedApplyActivityEndTime() == null){
                        return ResultUtil.error(-1,"审核后活动时间为空");
                    }
                    //是否已经参加过活动
                    String sql = "select * from activity_goods where goods_def_id = ? ";
                    SQLReady sqlReady = new SQLReady(sql,goodsDef.getGoodsDefId());
                    List<ActivityGoods> activityGoods = sqlManager.execute(sqlReady,ActivityGoods.class);
                    if(activityGoods.size() > 0){
                        //该商品活动已经参与活动，比较活动类型和时间，有修改则不允许通过
                        if(activityGoods.get(0).getActivityTypeId().intValue() != goodsDefs.get(0).getApplyActivityTypeId().intValue() ||
                                activityGoods.get(0).getActivityStartTime() != goodsDefs.get(0).getApplyActivityStartTime() ||
                                activityGoods.get(0).getActivityEndTime() != goodsDefs.get(0).getApplyActivityEndTime()){

                            if(openid.size() > 0){
                                //审核失败推送商户
                                weChatPushMessageUtil.goodsShenHeResultNo(goodsDefs.get(0).getGoodsDefId().toString(),openid.get(0));
                                log.info("审核结果推送商户完成");
                            }

                            return ResultUtil.error(-1,"活动商品不允许修改活动类型和活动时间");
                        }else{
                            if(openid.size() > 0){
                                //审核通过推送商户
                                weChatPushMessageUtil.goodsShenHeResultYes(goodsDefs.get(0).getGoodsDefId().toString(),openid.get(0));
                                log.info("审核结果推送商户完成");
                            }
                        }
                    }else{
                        //该商品第一次参与活动，直接插入活动表
                        ActivityGoods activityGoods1 = new ActivityGoods();
                        activityGoods1.setGoodsDefId(goodsDefs.get(0).getGoodsDefId());
                        activityGoods1.setActivityTypeId(goodsDefs.get(0).getApplyActivityTypeId());
                        activityGoods1.setStatus("1");
                        activityGoods1.setActivityStartTime(goodsDef.getVerifiedApplyActivityStartTime());
                        activityGoods1.setActivityEndTime(goodsDef.getVerifiedApplyActivityEndTime());
                        activityGoodsDao.insert(activityGoods1);
                        //将活动时间改为工作人员传的时间，可以是没变的，也可以是变了的
                        GoodsDef goodsDef1 = new GoodsDef();
                        goodsDef1.setGoodsDefId(goodsDef.getGoodsDefId());
                        goodsDef1.setApplyActivityStartTime(goodsDef.getVerifiedApplyActivityStartTime());
                        goodsDef1.setApplyActivityEndTime(goodsDef.getVerifiedApplyActivityEndTime());
                        goodsDefDao.updateTemplateById(goodsDef1);

                        //查询改商品记录的更新人openid
                        try {
                            if(openid.size() > 0){
                                //审核通过推送商户
                                weChatPushMessageUtil.goodsShenHeResultYes(goodsDefs.get(0).getGoodsDefId().toString(),openid.get(0));
                                log.info("审核结果推送商户完成");
                            }
                        }catch (Exception e){
                            e.printStackTrace();
                            log.error("推送商户失败",e);
                        }
                    }
                }
            }
        }

        SessionInfo sessionInfo = sessionInfoUtils.getSessionInfoByAuth(request);
//        goodsDefDao.updateById(goodsDef);
        goodsDef.setUpdaterUserid(sessionInfo.getUserId());
        goodsDef.setUpdateTime(new Date());
        if(goodsDef.getStatus().intValue() == 0){
            //审核退回
            goodsDef.setAuditMsg(goodsDef.getAuditMsg());
            goodsDef.setAuditTime(new Date());
            goodsDef.setAuditUser(sessionInfo.getUserId());
        }
        if(goodsDef.getStatus().intValue() == 1){
            //审核通过
            goodsDef.setAuditTime(new Date());
            goodsDef.setAuditUser(sessionInfo.getUserId());
        }

        goodsDefDao.updateTemplateById(goodsDef);
        return ResultUtil.success();
    }

    @Transactional
    public Result updateStatusById(GoodsDef goodsDef, HttpServletRequest request) {
        //判断值为空
        if(goodsDef.getGoodsDefId() == null){
            return ResultUtil.error(-1,"id为空");
        }

        if(goodsDef.getStatus() == null){
            return ResultUtil.error(-1,"状态为空");
        }

        List<GoodsDef> goodsDefs = goodsDefDao.execute("select * from goods_def where goods_def_id = ?",goodsDef.getGoodsDefId());
        //查询改商品记录的更新人openid
        String sql1 = "select b.openid from user_link_unionid a left join we_chat_user_info b on a.unionid = b.unionid where a.user_id = ? and b.source = 1";
        SQLReady sqlReady1 = new SQLReady(sql1,goodsDefs.get(0).getUpdaterUserid());
        List<String> openid = sqlManager.execute(sqlReady1,String.class);
        //下架商品需要判断是否为活动商品，以及是否在活动时间内下架，活动时间内不允许下架
        if(goodsDef.getStatus().intValue() == 2){
            if(goodsDefs.size() > 0){
                if(goodsDefs.get(0).getApplyActivityTypeId() != null){
                    String sql = "select * from activity_goods where goods_def_id = ? and status = '1' and now() >= activity_start_time and now() <= activity_end_time";
                    SQLReady sqlReady = new SQLReady(sql,goodsDef.getGoodsDefId());
                    List<Map> activityGoods = sqlManager.execute(sqlReady,Map.class);
                    if(activityGoods.size() > 0){
                        //该商品活动已经开始，不允许下架
                        return ResultUtil.error(-1,"该商品活动已经开始，不允许下架");
                    }
                }
            }
        }

        //审核上架商品需要判断是否为活动商品，以及是否修改过活动类型和活动时间，修改过不允许审核通过上架
        if(goodsDef.getStatus().intValue() == 1){
            if(goodsDefs.size() > 0){
                if(goodsDefs.get(0).getApplyActivityTypeId() != null){
                    if(goodsDef.getVerifiedApplyActivityStartTime() == null || goodsDef.getVerifiedApplyActivityEndTime() == null){
                        return ResultUtil.error(-1,"审核后活动时间为空");
                    }
                    //是否已经参加过活动
                    String sql = "select * from activity_goods where goods_def_id = ? ";
                    SQLReady sqlReady = new SQLReady(sql,goodsDef.getGoodsDefId());
                    List<ActivityGoods> activityGoods = sqlManager.execute(sqlReady,ActivityGoods.class);
                    if(activityGoods.size() > 0){
                        //该商品活动已经参与活动，比较活动类型和时间，有修改则不允许通过
                        if(activityGoods.get(0).getActivityTypeId().intValue() != goodsDefs.get(0).getApplyActivityTypeId().intValue() ||
                            activityGoods.get(0).getActivityStartTime() != goodsDefs.get(0).getApplyActivityStartTime() ||
                            activityGoods.get(0).getActivityEndTime() != goodsDefs.get(0).getApplyActivityEndTime()){

                            if(openid.size() > 0){
                                //审核失败推送商户
                                weChatPushMessageUtil.goodsShenHeResultNo(goodsDefs.get(0).getGoodsDefId().toString(),openid.get(0));
                                log.info("审核结果推送商户完成");
                            }

                            return ResultUtil.error(-1,"活动商品不允许修改活动类型和活动时间");
                        }else{
                            if(openid.size() > 0){
                                //审核通过推送商户
                                weChatPushMessageUtil.goodsShenHeResultYes(goodsDefs.get(0).getGoodsDefId().toString(),openid.get(0));
                                log.info("审核结果推送商户完成");
                            }
                        }
                    }else{
                        //该商品第一次参与活动，直接插入活动表
                        ActivityGoods activityGoods1 = new ActivityGoods();
                        activityGoods1.setGoodsDefId(goodsDefs.get(0).getGoodsDefId());
                        activityGoods1.setActivityTypeId(goodsDefs.get(0).getApplyActivityTypeId());
                        activityGoods1.setStatus("1");
                        activityGoods1.setActivityStartTime(goodsDef.getVerifiedApplyActivityStartTime());
                        activityGoods1.setActivityEndTime(goodsDef.getVerifiedApplyActivityEndTime());
                        activityGoodsDao.insert(activityGoods1);
                        //将活动时间改为工作人员传的时间，可以是没变的，也可以是变了的
                        GoodsDef goodsDef1 = new GoodsDef();
                        goodsDef1.setGoodsDefId(goodsDef.getGoodsDefId());
                        goodsDef1.setApplyActivityStartTime(goodsDef.getVerifiedApplyActivityStartTime());
                        goodsDef1.setApplyActivityEndTime(goodsDef.getVerifiedApplyActivityEndTime());
                        goodsDefDao.updateTemplateById(goodsDef1);

                        //查询改商品记录的更新人openid
                        try {
                            if(openid.size() > 0){
                                //审核通过推送商户
                                weChatPushMessageUtil.goodsShenHeResultYes(goodsDefs.get(0).getGoodsDefId().toString(),openid.get(0));
                                log.info("审核结果推送商户完成");
                            }
                        }catch (Exception e){
                            e.printStackTrace();
                            log.error("推送商户失败",e);
                        }
                    }
                }
            }
        }


        SessionInfo sessionInfo = sessionInfoUtils.getSessionInfoByAuth(request);
//        goodsDefDao.executeUpdate("update goods_def set status = ? where goods_def_id = ?",goodsDef.getStatus(),goodsDef.getGoodsDefId());
        GoodsDef goodsDef1 = new GoodsDef();
        goodsDef1.setStatus(goodsDef.getStatus());
        goodsDef1.setGoodsDefId(goodsDef.getGoodsDefId());
        goodsDef1.setUpdaterUserid(sessionInfo.getUserId());
        goodsDef1.setUpdateTime(new Date());
        if(goodsDef.getStatus().intValue() == 0){
            //审核退回
            goodsDef.setAuditMsg(goodsDef.getAuditMsg());
            goodsDef.setAuditTime(new Date());
            goodsDef.setAuditUser(sessionInfo.getUserId());
            weChatPushMessageUtil.goodsShenHeResultNo(goodsDefs.get(0).getGoodsDefId().toString(),openid.get(0));
            log.info("审核退回推送商户完成");
        }
        if(goodsDef.getStatus().intValue() == 1){
            //审核通过
            goodsDef.setAuditTime(new Date());
            goodsDef.setAuditUser(sessionInfo.getUserId());
        }
        goodsDefDao.updateTemplateById(goodsDef1);
        return ResultUtil.success();
    }

    @Transactional
	public Result updateTemplateById(GoodsDef goodsDef) {
        goodsDefDao.updateTemplateById(goodsDef);
        return ResultUtil.success();
    }
    @Transactional
    public Result removeById(QueryParamsGoodsDefDel goodsDefId) {
        if(goodsDefId.getGoodsDefId() == null){
            return ResultUtil.error(-1,"商品id为空");
        }
        goodsDefDao.executeUpdate("update goods_def set status = -3 where goods_def_id = ?",goodsDefId.getGoodsDefId());
        return ResultUtil.success();
    }

    @Transactional
    public Result removeByIds(List<Integer> ids) {
        for (Integer id:ids) {
            goodsDefDao.executeUpdate("update goods_def set status = -3 where goods_def_id = ?",id);
        }
        return ResultUtil.success();
    }


    public Result getGoodsTypeInStore(HttpServletRequest request) {
        if(sessionInfoUtils.getSessionInfoByAuth(request).getPartnerId() == null){
            //是主店
            SQLReady sqlReady = new SQLReady("select a.*,b.major_name from major_branch_partner a left join major_type b on a.major_type_id = b.major_type_id where b.status = 1 and branch_id = ? and partner_id is null",sessionInfoUtils.getSessionInfoByAuth(request).getBranchId());
            List<Map> list = sqlManager.execute(sqlReady,Map.class);
            return ResultUtil.success(list);
        }else{
            //是分店
            SQLReady sqlReady = new SQLReady("select a.*,b.major_name from major_branch_partner a left join major_type b on a.major_type_id = b.major_type_id where b.status = 1 and a.partner_id = ? and a.branch_id = ?",sessionInfoUtils.getSessionInfoByAuth(request).getPartnerId(),sessionInfoUtils.getSessionInfoByAuth(request).getBranchId());
            List<Map> list = sqlManager.execute(sqlReady,Map.class);
            return ResultUtil.success(list);
        }

    }
}
